package com.zjut.spider;

import org.apache.http.entity.mime.Header;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Ryan on 2016/10/31.
 */
public class HttpGet {

    private String baseUrl;
    private Map<String,String> parameter;
    private Header header;
    private String DBDid;

    public String getDBDid() {
        return DBDid;
    }

    public void setDBDid(String DBDid) {
        this.DBDid = DBDid;
    }

    public HttpGet() {
        parameter = new HashMap<String, String>();
    }
    public HttpGet(String baseUrl) {
        parameter = new HashMap<String, String>();
        this.baseUrl = baseUrl;
    }
    public HttpGet(String baseUrl, Map<String,String> parameter) {
        this.parameter = parameter;
        this.baseUrl = baseUrl;
    }
    public String buildUrl(){
        String getURL;
        if(baseUrl==null||baseUrl.equals("")){
            return "";
        }
        getURL = baseUrl;
        if(parameter.size()!=0){
            getURL+="?";
            for(Map.Entry<String,String> entry:parameter.entrySet()){
                getURL+=entry.getKey()+"="+entry.getValue()+"&";
            }
        }
        return getURL;
    }

    public void addParameter(String key, String value) {
        this.parameter.put(key, value);
    }
    public void removeParameter(String key) {
        this.parameter.remove(key);
    }

    public String getBaseUrl() {
        return baseUrl;
    }

    public void setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
    }
}
